package com.dingwen.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.UUID;

/**
 * order controller
 *
 * @author dingwen
 * 2021.07.14 15:58
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    private final RestTemplate restTemplate;
    private static final String PAYMENT_URI = "http://consul-provider-payment";

    @Autowired
    public OrderController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    /**
     * consul 测试
     *
     * @return {@link String}
     */
    @GetMapping("/consul")
    public String find() {
        return restTemplate.getForObject(PAYMENT_URI + "/payment/consul", String.class);
    }
}
